home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / recover / analyzeCommit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.5 KB  |  196 lines

  1. /*
  2.  *   $RCSfile: analyzeCommit.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:55 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "latch.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "openlog.h"
  58. #include "trans.h"
  59. #include "logrecs.h"
  60. #include "logaction.h"
  61. #include "util_funcs.h"
  62. #include "log_intfuncs.h"
  63. #include "log_extfuncs.h"
  64. #include "recover_intfuncs.h"
  65. #include "recover_extfuncs.h"
  66. #include "trans_extfuncs.h"
  67. #include "thread_globals.h"
  68. #include "trans_globals.h"
  69. #include "distr.h"
  70. #include "distr_globals.h"
  71.  
  72.  
  73.  void
  74. analyzeCommit (
  75.  
  76.     register LOGRECORDHDR    *record 
  77. )
  78. {
  79.     
  80.     register TRANSREC        *transRec;
  81.  
  82.  
  83.     TRPRINT(TR_LOG|TR_RECOVER, TR_LEVEL_1, ("recordLSN:%d tid:%x type:%d action:%d",
  84.             record->recordLSN.offset, record->tid, record->type, record->action));
  85.  
  86.     /*
  87.      *    check to see if there is a transaction record
  88.      */
  89.     if ((transRec = findTransRec(record->tid)) == NULL)    {
  90.  
  91.         SM_ERROR(TYPE_LOG, esmINTERNAL);
  92.         return;
  93.     }
  94.  
  95.     /*
  96.      *    process the record
  97.      */
  98.     switch (record->action) {
  99.  
  100.         case LOG_ACTION_DISTR_COORD_COMMIT:
  101.             
  102.             /*
  103.              *  change the state to commit
  104.              */
  105.             transRec->transState = T_COMMIT;
  106.  
  107.             /*
  108.              *    note the client command
  109.              */
  110.             transRec->clientCommand = C_COMMIT;
  111.  
  112.             break;
  113.         
  114.         case LOG_ACTION_DISTR_COORD_COMMIT_READONLY:
  115.  
  116.             /*
  117.              *    initialize the state to inactive
  118.              */
  119.             transRec->transState = T_INACTIVE;
  120.  
  121.             /*
  122.              *    initialize the list components
  123.              */
  124.             listRemove( &(transRec->activeTransList) );
  125.  
  126.             /*
  127.              *    check to see if the transaction is on the list of 
  128.              *    distr trans - this may not be so because we don't
  129.              *    write a prepare record for READONLY transactions
  130.              */
  131.             if (LIST_MEMBER(&(transRec->distrTransList))) {
  132.  
  133.                 /*
  134.                  *    remove the transRec from the list of distr trans
  135.                  */
  136.                 listRemove( &(transRec->distrTransList) );
  137.                 numActiveCoordDistrTrans--;
  138.             }
  139.  
  140.             /*
  141.              *    move the transaction to the free pool
  142.              */
  143.             poolMove( &TransRecPool, &(transRec->tidList) );
  144.             break;
  145.  
  146.         case LOG_ACTION_DISTR_SERVER_COMMIT:
  147.         case NULL:
  148.  
  149.             /*
  150.              *  Remove all pages from the dirty page table which were
  151.              *  deallocated by this transaction.
  152.              */
  153.             removeDeallocedDirtyPages(transRec);
  154.  
  155.             /*
  156.              *    initialize the state to inactive
  157.              */
  158.             transRec->transState = T_INACTIVE;
  159.         
  160.             /*
  161.              *    initialize the list components
  162.              */
  163.             listRemove( &(transRec->activeTransList) );
  164.  
  165.             /*
  166.              *    check if this is a distributed transaction
  167.              */
  168.             if (LIST_MEMBER(&(transRec->distrTransList))) {
  169.  
  170.                 /*
  171.                  *    take it off the list of active distr transactions
  172.                  */
  173.                 listRemove( &(transRec->distrTransList) );
  174.  
  175.                 /*
  176.                  *    decrement the number of active distr transactions
  177.                  */
  178.                 numActiveServerDistrTrans--;
  179.             }
  180.  
  181.             /*
  182.              *    move the transaction to the free pool
  183.              */
  184.             poolMove( &TransRecPool, &(transRec->tidList) );
  185.             break;
  186.  
  187.         default:
  188.  
  189.             TRPRINT(TR_RECOVER, TR_LEVEL_1, 
  190.                 ("unknown action %d", record->action));
  191.             SM_ERROR(TYPE_FATAL, esmINTERNAL);
  192.             break;
  193.  
  194.     }
  195. }
  196.